# 随机森林的并行计算
library(randomForest)

cl <- makeCluster(4)
registerDoParallel(cl)
rf <- foreach(ntree=rep(25000, 4), 
              .combine=combine,
              .packages='randomForest') %dopar%
  randomForest(Species~., data=iris, ntree=ntree)

stopCluster(cl)
